<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>动画原理</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
				box-sizing: border-box;
			}
			div {
				position: absolute;
				top: 0;
				left: 0;
				width: 200px;
				height: 200px;
				background-color: pink;
			}
		</style>
	</head>
	<body>
		<div>
			
		</div>
		
		<script type="text/javascript">
			var div = document.querySelector('div');
			var timer = null;
			timer = setInterval(function() {
				if(div.offsetLeft >= 400) {
					clearInterval(timer)
				}
				div.style.left = div.offsetLeft + 5 + 'px'
			},30);
		</script>
	</body>
</html>
